﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<System.Collections.Generic.IEnumerable<GabageFactory.Models.Message>>" %>
<%@ Import Namespace="System.Collections.Generic" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	通知列表
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% using (Html.BeginForm("Index","Message", FormMethod.Get))
    {%>
    
    
    <div class="search_bar">
        <span class="left_s"></span>
        <%
            User user = (User)ViewData["user"];
        %>
        <%if (user.RoleId == (int)RoleEnum.Administrator){ %>
        <label>所属公司：</label>
        <%= Html.DropDownList("factoryId", ViewData["factories"] as List<SelectListItem>, "请选择公司")%>
        <%
        }
        else
        { 
        %>
        <%= Html.Hidden("factoryId", user.FactoryId)%>
        <%
        }
        %>
        <label style="margin-left:1em;">开始时间：</label>
        <input type="text" id="beginTime" name="beginTime" value="" size="14" readonly="readonly"/>
        <label style="margin-left:1em;">结束时间：</label>
        <input type="text" id="endTime" name="endTime" value="" size="14" readonly="readonly"/>
        <label style="margin-left:1em;">关键字：</label>
        <input type="text" name="name" value="" size="12" maxlength="50"/>
        <input type="submit" value="搜 索" />
    </div>

    <%} %>	


    <p class="sys_create_btn">
        <%= Html.ActionLink("创建通知", "Create") %>
    </p>

    <table class="style_table2" cellpadding="4" cellspacing="0" border="0" style="margin-top:20px;"> 
       <tr>
    	    <th style="width:60px; text-align:center;">通知ID</th>
		    <th style="width:200px; text-align:center;">所属公司</th>
            <th style="text-align:center;">通知内容</th>
            <th style="width:150px; text-align:center;">开始时间</th>
            <th style="width:150px; text-align:center;">结束时间</th>
		    <th style="width:80px; text-align:center;">操作</th>
	    </tr>
        <% IDictionary<long, string> allFactories = (IDictionary<long, string>)ViewData["allFactories"];%>
        <% foreach (var item in Model) { %>
	    <tr onmouseover="this.className='trbgmouseover'"  onmouseout="this.className='trmouseout' ">
	        <td style="text-align:center;"><%= item.Id %></td>
		    <td> 
            <%
                if (item.FactoryId > 0)
                {
            %>
            <%= allFactories[item.FactoryId]%>
            <%
                }
                else
                {
            %>
            所有公司
            <%
                }
            %>
            </td>

		    <td> <%= item.content %></td>
            <td style="text-align:center;"> <%= item.beginTime %></td>
            <td style="text-align:center;"> <%= item.endTime %></td>
		    <td style="text-align:center;">
                 <%= Html.ActionLink("编辑", "Edit", new { id=item.Id }) %> |
                <%= Html.ActionLink("删除", "Delete", new { id = item.Id }, new { onclick=@"return confirm('确定删除该通知吗？');"})%>
            </td>
        </tr>
        <%} %>
    </table>

    
    <script type="text/javascript" language="javascript">
        $('#beginTime').datetimepicker({
            showSecond: true,
            timeFormat: 'hh:mm:ss'
        });

        $('#endTime').datetimepicker({
            showSecond: true,
            timeFormat: 'hh:mm:ss'
        });
    </script>
</asp:Content>